import request from '@/utlis/request'
import type { TradeMarkResponseData, TradeMark } from './type'
enum API {
  TRADEMARK_URL = '/admin/product/baseTrademark/',
  ADDTRADEMARK_URL = '/admin/product/baseTrademark/save',
  UPDATETRADEMARK_URL = '/admin/product/baseTrademark/update',
  DELETE_URL = '/admin/product/baseTrademark/remove/',
}

//品牌管理
export const reqHasTrademake = (page: number, limit: number) =>
  request.get<any, TradeMarkResponseData>(
    API.TRADEMARK_URL + `${page}/${limit}`,
  )

// 添加与修改已有品牌
export const reqAddorUpdateTrademake = (data: TradeMark) => {
  // 如果有id就是修改
  if (data.id) {
    return request.put<any, any>(API.UPDATETRADEMARK_URL, data)
  } else {
    // 没有id就新增
    return request.post<any, any>(API.ADDTRADEMARK_URL, data)
  }
}

// 删除某一条已有品牌的数据
export const reqDeleteTrademake = (id) =>
  request.delete<any, any>(API.DELETE_URL + id)
